package com.ncucoder.flyweight;

import com.ncucoder.flyweight.impl.Circle;

import java.util.HashMap;

/**
 * @author <a href="https://edit.ncucoder.com">hsowan</a>
 * @since 2018-12-13 20:33
 */
public class ShapeFactory {
    private static final HashMap<String, Shape> CIRCLE_MAP = new HashMap<>();

    public static Shape getCircle(String color) {
        Circle circle = (Circle)CIRCLE_MAP.get(color);

        if(circle == null) {
            circle = new Circle(color);
            CIRCLE_MAP.put(color, circle);
            System.out.println("Creating circle of color : " + color);
        }
        return circle;
    }
}
